package com.pig4cloud.pig.admin.controller;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.admin.api.entity.NewsList;
//import com.pig4cloud.pig.admin.constant.NewsListTest;
//import com.pig4cloud.pig.admin.mapper.NewsListTestMapper;
import com.pig4cloud.pig.admin.service.NewsListService;
import com.pig4cloud.pig.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.pig4cloud.pig.common.security.annotation.Inner;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/gatherNews")
public class GatherNewsController {

	@Autowired
	private NewsListService newsListService;

	@Operation(summary = "获取新闻分页列表", description = "获取新闻分页列表")
	@PostMapping("/page")
	public R getNews(@ParameterObject Page page, @ParameterObject NewsList newsList) {
		return R.ok(newsListService.getNewsListByPage(page, newsList));
	}

	@Inner
	@PostMapping("/batchInsert")
	public R batchInsert(@RequestBody List<NewsList> newsLists){
		Integer rows = newsListService.batchInsert(newsLists);
		return R.ok(rows);
	}

}
